from SCons.Options import *

def config_SDL_GL(env):
    "check for sdl and opengl and adjust environment if found"
    if env.has_key('sdl_sdk_path'):
	prefix = env['sdl_sdk_path']
	env.Append(
		CPPPATH = [ os.path.join(prefix, "include") ],
		CPPDEFINES = [ ('_GNU_SOURCE',1), 
			       ('main', 'SDL_main') ],
		LIBPATH = [ os.path.join(prefix, "lib") ],
		LIBS = ["mingw32", "SDLmain", "SDL", "opengl32", "glu32"],
		LINKFLAGS = ["-mwindows"])
    else:
	# XXX what if sdl-config can't be found?
	env.ParseConfig('sdl-config --cflags --libs')
	if env['PLATFORM'] == 'darwin':
	    env.Append(FRAMEWORKS = ['OpenGL'])
	else:
	    env.Append(LIBS = ['GLU', 'GL'])

def add_SDL_GL_Options(opts):
    if os.name == 'nt':
	opts.AddOptions(PathOption('sdl_sdk_path', 
	    'Path to SDL development installation',
	    None))
